﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhSystemBLL.orderData;
using dhSystemBLL.produceBLL;
using baseSet.importExport;
using dhsystem.Main;
using dhDataAcess.baseBLL;


namespace dhsystem.produceForm.Stock
{
    public partial class FrmV_orderstockOut : Form
    {
        public FrmV_orderstockOut()
        {
            InitializeComponent();
        }
        orderStockOutBLL orderStockOut = new orderStockOutBLL();
        packStockInBLL packStockIn = new packStockInBLL();
        private void toolStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void FrmV_orderstockOut_Load(object sender, EventArgs e)
        {

            bgSourcepacking.DataSource = packStockIn.getpackCountAll();
            dGridpacking.DataSource = bgSourcepacking;
            DcolumnSet.colSet(moduleInfo.VpackCount, dGridpacking);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridpacking.RowCount.ToString() + "条";



        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bgSourcepacking.DataSource = q.sqlQueryLikeAll(moduleInfo.VpackCount, textMatNameQuery.Text.ToString().Trim());
                dGridpacking.DataSource = bgSourcepacking;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void buttupdate_Click(object sender, EventArgs e)
        {
            bgSourcepacking.DataSource = packStockIn.getpackCountAll();
            dGridpacking.DataSource = bgSourcepacking;
            DcolumnSet.colSet(moduleInfo.VpackCount, dGridpacking);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridpacking.RowCount.ToString() + "条";
        }

        private void toolQuery_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.VpackCount);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridpacking.DataSource = query.rTable;
            }
        }

        private void toolExport_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.VpackCount, dGridpacking, "仓库信息");
            frm.ShowDialog();
        }

        private void toolStripMaterialList_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            this.Close();
        }

        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            //未出库
            if (e.TabPage == tabPage1)
            {
                bgSourcepacking.DataSource = packStockIn.getpackCountAll();
                dGridpacking.DataSource = bgSourcepacking;
                DcolumnSet.colSet(moduleInfo.VpackCount, dGridpacking);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridpacking.RowCount.ToString() + "条";
            }
            //已出库
            if (e.TabPage == tabPage2)
            {
                bSourcepackend.DataSource = orderStockOut.getV_orderStockOutALL();
                dGridViewpackend.DataSource = bSourcepackend;
                DcolumnSet.colSet(moduleInfo.V_orderStockOut, dGridViewpackend);
                toolStripStatusLabel1.Text = "数据总条数:" + dGridViewpackend.RowCount.ToString() + "条";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bSourcepackend.DataSource = orderStockOut.getV_orderStockOutALL();
            dGridViewpackend.DataSource = bSourcepackend;
            DcolumnSet.colSet(moduleInfo.V_orderStockOut, dGridViewpackend);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridViewpackend.RowCount.ToString() + "条";
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.V_orderStockOut);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridViewpackend.DataSource = query.rTable;
            }
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.V_orderStockOut, dGridViewpackend, "仓库信息");
            frm.ShowDialog();
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.VpackCount, dGridpacking, "仓库信息");
            frm.ShowDialog();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.VpackCount);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridpacking.DataSource = query.rTable;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bSourcepackend.DataSource = q.sqlQueryLikeAll(moduleInfo.V_orderStockOut, textBox1.Text.ToString().Trim());
                dGridViewpackend.DataSource = bSourcepackend;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            //bgSourcepacking.DataSource = basicSql.getVpackCount(dateTimePicker1.Value.ToString(), dateTimePicker2.Value.ToString());
            //dGridpacking.DataSource = bgSourcepacking;
            //DcolumnSet.colSet(moduleInfo.VpackCount, dGridpacking);
            //toolStripStatusLabel1.Text = "数据总条数:" + dGridpacking.RowCount.ToString() + "条";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            bSourcepackend.DataSource = basicSql.getV_orderStockOut(dateTimePicker4.Value.ToString(), dateTimePicker3.Value.ToString());
            dGridViewpackend.DataSource = bSourcepackend;
            DcolumnSet.colSet(moduleInfo.V_orderStockOut, dGridViewpackend);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridViewpackend.RowCount.ToString() + "条";
        }
    }
}
